/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.controller;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import oracle.jdbc.OracleTypes;
import queenb.net.annotation.Mapping;
import queenb.net.entitybean.A000;
import queenb.net.entitybean.V220;
import queenb.web.store.A000Store;
import queenb.web.supplier.store.V220Store;
import queenb.web.util.ComboboxUtil;
import queenb.web.util.ContextUtil;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;

/**
 *
 * @author DUYNGUYEN
 */
public class V220Controller extends QueenbController {

    /**
     * @return the itemservice
     */
    public static int getItemservice() {
        return itemservice;
    }

    /**
     * @param aItemservice the itemservice to set
     */
    public static void setItemservice(int aItemservice) {
        itemservice = aItemservice;
    }
    private int pv220;
    private int pv200;
    private String ncc;
    private int fk100;//NCC
    private int pk100;
    private int fa000;//Tinh thanh
    private int fn750;
    private int fv200;
    private String vv223; // tem dich vu
    private String vv225;// mo ta
    private String vv201;
    private String vv228;
    private String vv227;
    private String av001;
    private int vn224;
    private java.util.Date vd221;
    private java.util.Date vd222;
    private String vd221st;
    private String vd222st;
    private String vn228;
    private String vn228Str;
    private V220Store store;
    private List<queenb.net.entitybean.V220> listsevice;
    private List<SelectItem> combN750 = new ArrayList<SelectItem>();
    private List<SelectItem> combA000 = new ArrayList<SelectItem>();
    private List<SelectItem> combV200 = new ArrayList<SelectItem>();
    private List<SelectItem> combk100 = new ArrayList<SelectItem>();
    private List<SelectItem> comb4N750 = new ArrayList<SelectItem>();
    private List<SelectItem> comb4A000 = new ArrayList<SelectItem>();
    private List<SelectItem> comb4V200 = new ArrayList<SelectItem>();
    private List<SelectItem> comb4k100 = new ArrayList<SelectItem>();
    private static int itemservice; // id dich vu
    private ComboboxUtil comBoboxUtil = new ComboboxUtil();
    private int n750;
    private int a000;
    private int v200;
    private String pagecurent;
    //paging
    private int Offset = 0;
    private int Limit = 30;
    private int totalrow; // tong so dong
    private int totalpage; // tong so trang
    private int current; // traung hien tai
    static private int numrow = 30; // so dong tren 1 trang
    private int start; // bat dau lay tu record
    private int end; // lay tu record so
    private int startpage = 1; // page bat dau
    private int endpage = 1;   // page ket thuc
    private String pagename = "";
    private int totalcurent;

    public V220Controller() {
        store = new V220Store();
        Object ser = getRequest().getParameter("ser");
        if (ser == null) {
            // truong hop submit
        } else {
            SessionProvider.setSessionMapValue("n750", null);
            SessionProvider.setSessionMapValue("a000", null);
            SessionProvider.setSessionMapValue("fk100", null);
            SessionProvider.setSessionMapValue("v200", null);

            SessionProvider.setSessionMapValue("fn750", null);
            SessionProvider.setSessionMapValue("fa000", null);
            SessionProvider.setSessionMapValue("pk100", null);
            SessionProvider.setSessionMapValue("fv200", null);
        }
        Object objid = getRequest().getParameter("id");
        Object objn750 = getRequest().getParameter("fn750");
        Object objaction = getRequest().getParameter("action");
        Object objfk100 = getRequest().getParameter("fk100");
        Object objfv200 = getRequest().getParameter("fv200");
        Object objfa000 = getRequest().getParameter("fa000");
        Object objpage = getRequest().getParameter("page");
        if (objaction != null) {
            if (objaction.toString().equals("add")) {
                pv220 = 0;
                // pagecurent = objpage.toString();
            } else if (objaction.toString().equals("edit")) {
                try {
                    fn750 = Integer.parseInt(objn750.toString());
                    pk100 = Integer.parseInt(objfk100.toString());
                    fv200 = Integer.parseInt(objfv200.toString());
                    fa000 = Integer.parseInt(objfa000.toString());
                    pv220 = Integer.parseInt(objid.toString());

                    getListV220ById(pv220, fv200, fa000, fn750, pk100);
                } catch (Exception e) {
                }
            }
        }

        //paging
        int a;
        System.out.println("D:-- listEmployee is not null ");
        Object ppage = getRequest().getParameter("p");
        if (ppage != null) {
            try {
                a = Integer.parseInt(ppage.toString());
            } catch (Exception ex) {
                a = 1;
            }
            if (a == 1) {
                setCurrent(1);
                setOffset(0);
                System.out.println("D:-- setOffset: " + 0);
            } else {
                setCurrent(a);
                setOffset((a - 1) * Limit);
                System.out.println("D:-- setOffset: " + ((a - 1) * Limit));
            }
            System.out.println("D:-- page: " + a);

        } else {
            SessionProvider.setSessionMapValue("typeSearchSEVICE", null);
            SessionProvider.setSessionMapValue("keySearchSEVICE", null);
            setCurrent(1);
            setOffset(0);
            System.out.println("D:-- page: 1");
        }
    }

    public void changeCountry(ActionEvent ac) {
        System.out.println("D:---change Country " + n750);
        SessionProvider.setSessionMapValue("n750", n750);
        SessionProvider.setSessionMapValue("a000", null);
        SessionProvider.setSessionMapValue("fk100", null);
        SessionProvider.setSessionMapValue("v200", null);
    }

    public void changeCity(ActionEvent ac) {
        System.out.println("D:---change City " + a000);
        SessionProvider.setSessionMapValue("a000", a000);
        SessionProvider.setSessionMapValue("fk100", null);
        SessionProvider.setSessionMapValue("v200", null);
    }

    public void changeNcc(ActionEvent ac) {
        System.out.println("D:---change changeNcc " + fk100);
        SessionProvider.setSessionMapValue("fk100", fk100);
    }

    public void changeldv(ActionEvent ac) {
        System.out.println("D:---change changeldv " + v200);
        SessionProvider.setSessionMapValue("v200", v200);
        SessionProvider.setSessionMapValue("fk100", null);
    }

    public void change4Country(ActionEvent ac) {
        System.out.println("D:---change change4Country " + fn750);
        SessionProvider.setSessionMapValue("fn750", fn750);
        SessionProvider.setSessionMapValue("fa000", null);
        SessionProvider.setSessionMapValue("pk100", null);
        SessionProvider.setSessionMapValue("fv200", null);

    }

    public void change4City(ActionEvent ac) {
        System.out.println("D:---change change4City " + fa000);
        SessionProvider.setSessionMapValue("fa000", fa000);
        SessionProvider.setSessionMapValue("pk100", null);
        SessionProvider.setSessionMapValue("fv200", null);
    }

    public void change4Ncc(ActionEvent ac) {
        System.out.println("D:---change change4Ncc " + pk100);
        SessionProvider.setSessionMapValue("pk100", pk100);
    }

    public void change4ldv(ActionEvent ac) {
        System.out.println("D:---change change4ldv " + fv200);
        SessionProvider.setSessionMapValue("fv200", fv200);
        SessionProvider.setSessionMapValue("pk100", null);

    }

    public void getListV220ById(int pnFV220, int pnFV200, int pnFA000, int pnFN750, int pnFK100) {
        System.out.println("getListV220All(int pnFH000, int pnFH200, int pnFV220, int pnFV200, int pnFA000, int pnFN750, int pnFK100, String pvLOGIN)");
        System.out.println("D: getListV220All : (" + getLogin().getModule() + " , " + getLogin().getCompanyNo() + " , " + pnFV220 + " , " + pnFV200 + " , " + pnFA000 + " , " + pnFN750 + " , " + pnFK100 + " , " + getLogin().getUserName());
        List<V220> list = new ArrayList<V220>();
        list = store.getListV220All(getLogin().getModule(), getLogin().getCompanyNo(), pnFV220, pnFV200, pnFA000, pnFN750, pnFK100, getLogin().getUserName());
        if (list != null || list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                this.fn750 = list.get(i).getFn750();
                SessionProvider.setSessionMapValue("fn750", fn750);
                this.fa000 = list.get(i).getFa000();
                SessionProvider.setSessionMapValue("fa000", fa000);
                this.fv200 = list.get(i).getFv200();
                SessionProvider.setSessionMapValue("fv200", fv200);
                this.pk100 = list.get(i).getFk100();
                SessionProvider.setSessionMapValue("pk100", pk100);
                this.vv223 = list.get(i).getVv223();
                this.vn228 = list.get(i).getVn228();
                this.vv225 = list.get(i).getVv225();
                this.pv220 = list.get(i).getPv220();
                this.vd221 = list.get(i).getVd221();
                this.vd222 = list.get(i).getVd222();
                this.vv227 = list.get(i).getVv227();
                //SessionProvider.setSessionMapValue("pv220", pv220);
                System.out.println("D: list detail: " + fn750 + " , " + fa000 + " , " + fv200 + " , " + pk100 + " , " + vd221 + " , " + vd222 + " , " + vv223 + " , " + vv225 + " , " + vn228);
            }
        }
    }

    public void updateV220() {
        try {
            String dateStart = ContextUtil.getRequestParameter("to");
            String dateEnd = ContextUtil.getRequestParameter("from");
            if (!dateStart.equals("")) {
                vd221 = Util.parseDate(dateStart, "dd/MM/yyyy");
            } else {
                vd221 = null;
            }
            if (!dateEnd.equals("")) {
                vd222 = Util.parseDate(dateEnd, "dd/MM/yyyy");
            } else {
                vd222 = null;
            }

            System.out.println("updateV220(int pnPV220, int pnFH000, int pnFH200, int pnFK100, int pnFA000, int pnFV200, Date pdVD221, Date pdVD222, String pvVV223, int pnVN224, String pvVV225, String pvVV226, String pvVV227, double pnVN228, String pvLOGIN)");
            System.out.println("D: updateV220: (" + pv220 + " , " + getLogin().getModule() + " , " + getLogin().getCompanyNo() + " , " + pk100 + " , " + fa000 + " , " + fv200 + " , " + getVd221() + " , " + getVd222() + " , " + vv223 + " , " + 0 + " , " + vv225 + " , " + null + " , " + null + " , " + vn228 + " , " + getLogin().getUserName() + " )");
            int count = store.updateV220(pv220, getLogin().getModule(), getLogin().getCompanyNo(), pk100, fa000, fv200, Util.toSQLDate(getVd221()), Util.toSQLDate(getVd222()), vv223, 0, vv225, null, vv227, Integer.valueOf(vn228), getLogin().getUserName());
            if (count == 0) {
                showGlobalReport(true, getResourceString("datasuccessfail"));
            } else {
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            }
            sendRedirect("listSevice.jsp");
        } catch (Exception e) {
            System.out.println("D: error from updateV220: " + e.getMessage());
        }
    }

    /**
     * @return the pv220
     */
    public int getPv220() {
        return pv220;
    }

    /**
     * @param pv220 the pv220 to set
     */
    public void setPv220(int pv220) {
        this.pv220 = pv220;
    }

    /**
     * @return the pv200
     */
    public int getPv200() {
        return pv200;
    }

    /**
     * @param pv200 the pv200 to set
     */
    public void setPv200(int pv200) {
        this.pv200 = pv200;
    }

    /**
     * @return the ncc
     */
    public String getNcc() {
        return ncc;
    }

    /**
     * @param ncc the ncc to set
     */
    public void setNcc(String ncc) {
        this.ncc = ncc;
    }

    /**
     * @return the fk100
     */
    public int getFk100() {
        return fk100;
    }

    /**
     * @param fk100 the fk100 to set
     */
    public void setFk100(int fk100) {
        this.fk100 = fk100;
    }

    /**
     * @return the fa000
     */
    public int getFa000() {
        return fa000;
    }

    /**
     * @param fa000 the fa000 to set
     */
    public void setFa000(int fa000) {
        this.fa000 = fa000;
    }

    /**
     * @return the fn750
     */
    public int getFn750() {
        return fn750;
    }

    /**
     * @param fn750 the fn750 to set
     */
    public void setFn750(int fn750) {
        this.fn750 = fn750;
    }

    /**
     * @return the fv200
     */
    public int getFv200() {
        return fv200;
    }

    /**
     * @param fv200 the fv200 to set
     */
    public void setFv200(int fv200) {
        this.fv200 = fv200;
    }

    /**
     * @return the vv223
     */
    public String getVv223() {
        return vv223;
    }

    /**
     * @param vv223 the vv223 to set
     */
    public void setVv223(String vv223) {
        this.vv223 = vv223;
    }

    /**
     * @return the vv225
     */
    public String getVv225() {
        return vv225;
    }

    /**
     * @param vv225 the vv225 to set
     */
    public void setVv225(String vv225) {
        this.vv225 = vv225;
    }

    /**
     * @return the vv201
     */
    public String getVv201() {
        return vv201;
    }

    /**
     * @param vv201 the vv201 to set
     */
    public void setVv201(String vv201) {
        this.vv201 = vv201;
    }

    /**
     * @return the av001
     */
    public String getAv001() {
        return av001;
    }

    /**
     * @param av001 the av001 to set
     */
    public void setAv001(String av001) {
        this.av001 = av001;
    }

    /**
     * @return the vn224
     */
    public int getVn224() {
        return vn224;
    }

    /**
     * @param vn224 the vn224 to set
     */
    public void setVn224(int vn224) {
        this.vn224 = vn224;
    }

    /**
     * @return the vd221
     */
    public java.util.Date getVd221() {
        return vd221;
    }

    /**
     * @param vd221 the vd221 to set
     */
    public void setVd221(java.util.Date vd221) {
        this.vd221 = vd221;
    }

    /**
     * @return the vd222
     */
    public java.util.Date getVd222() {
        return vd222;
    }

    /**
     * @param vd222 the vd222 to set
     */
    public void setVd222(java.util.Date vd222) {
        this.vd222 = vd222;
    }

    /**
     * @return the vn228
     */
    public String getVn228() {
        return vn228;
    }

    /**
     * @param vn228 the vn228 to set
     */
    public void setVn228(String vn228) {
        this.vn228 = vn228;
    }

    /**
     * @return the vn228Str
     */
    public String getVn228Str() {
        return vn228Str;
    }

    /**
     * @param vn228Str the vn228Str to set
     */
    public void setVn228Str(String vn228Str) {
        this.vn228Str = vn228Str;
    }

    /**
     * @return the store
     */
    public V220Store getStore() {
        return store;
    }

    /**
     * @param store the store to set
     */
    public void setStore(V220Store store) {
        this.store = store;
    }

    /**
     * @return the listsevice
     */
    public List<queenb.net.entitybean.V220> getListsevice() {
        try {
            Object objn750 = SessionProvider.getSessionMapValue("n750");
            Object obja000 = SessionProvider.getSessionMapValue("a000");
            Object objv200 = SessionProvider.getSessionMapValue("v200");
            Object objfk100 = SessionProvider.getSessionMapValue("fk100");
            if (objn750 != null) {
                try {
                    n750 = Integer.parseInt(objn750.toString());
                } catch (Exception e) {
                    System.out.println("D:-- Error from convert n750: " + e.getMessage());
                    n750 = 0;
                }
            } else {
                n750 = 0;
            }

            if (obja000 != null) {
                try {
                    a000 = Integer.parseInt(obja000.toString());
                } catch (Exception e) {
                    System.out.println("D:-- Error from convert a000: " + e.getMessage());
                    a000 = 0;
                }
            } else {
                a000 = 0;
            }
            if (objv200 != null) {
                try {
                    v200 = Integer.parseInt(objv200.toString());
                } catch (Exception e) {
                    System.out.println("D:-- Error from convert v200: " + e.getMessage());
                    v200 = 0;
                }
            } else {
                v200 = 0;
            }

            if (objfk100 != null) {
                try {
                    fk100 = Integer.parseInt(objfk100.toString());
                } catch (Exception e) {
                    System.out.println("D:-- Error from convert fk100: " + e.getMessage());
                    fk100 = 0;
                }
            } else {
                fk100 = 0;
            }

            V220 v220;
            System.out.println(getLogin().getModule() + " , " + getLogin().getCompanyNo() + " , " + " 0, " + v200 + " , " + a000 + " , " + n750 + " , " + fk100 + " , " + getLogin().getUserName());
            listsevice = store.getListV220All(getLogin().getModule(), getLogin().getCompanyNo(), 0, v200, a000, n750, fk100, getLogin().getUserName());
//            if (Offset == 0) {
//                if (listsevice.size() > 0) {
//                    v220 = listsevice.get(0);
//                    if (v220 != null) {
//                        SessionProvider.setSessionMapValue("totalcurentSEVICE", v220.getRowss());
//                        //totalcurent = n100.getRowss();
//                    } else {
//                        SessionProvider.setSessionMapValue("totalcurentSEVICE", 0);
//                        //totalcurent = 0;
//                    }
//                } else {
//                    SessionProvider.setSessionMapValue("totalcurentSEVICE", 0);
//                    //totalcurent = 0;
//                }
//            }
            
            //paging
//        int t;
//        Object obj = SessionProvider.getSessionMapValue("totalcurentSEVICE");
//        if (obj != null) {
//            try {
//                t = Integer.parseInt(obj.toString());
//            } catch (Exception e) {
//                t = 0;
//            }
//            totalcurent = t;
//        } else {
//            totalcurent = 0;
//        }
//
//        setTotalrow(totalcurent);
        
            return listsevice;
        } catch (Exception e) {
            System.out.println("Erorr: from getListsevice: " + e.getMessage());
            return null;
        }

    }

    /**
     * @return the combN750
     */
    public List<SelectItem> getCombN750() {
        ComboboxUtil combo = new ComboboxUtil();
        combN750 = combo.getlistCombN750DV();
        return combN750;
    }

    /**
     * @param combN750 the combN750 to set
     */
    public void setCombN750(List<SelectItem> combN750) {
        this.combN750 = combN750;
    }

    /**
     * @return the comBoboxUtil
     */
    public ComboboxUtil getComBoboxUtil() {
        return comBoboxUtil;
    }

    /**
     * @param comBoboxUtil the comBoboxUtil to set
     */
    public void setComBoboxUtil(ComboboxUtil comBoboxUtil) {
        this.comBoboxUtil = comBoboxUtil;
    }

    /**
     * @return the n750
     */
    public int getN750() {
        return n750;
    }

    /**
     * @param n750 the n750 to set
     */
    public void setN750(int n750) {
        this.n750 = n750;
    }

    /**
     * @return the s200
     */
    public int getA000() {

        return a000;
    }

    /**
     * @param s200 the s200 to set
     */
    public void setA000(int A000) {
        this.a000 = A000;
    }

    /**
     * @return the combS200
     */
    public List<SelectItem> getCombA000() {
        ComboboxUtil combo = new ComboboxUtil();
        combA000 = combo.getListCombA000DV(n750);
        return combA000;
    }

    /**
     * @param combS200 the combS200 to set
     */
    public void setCombA000(List<SelectItem> combA000) {
        this.combA000 = combA000;
    }

    /**
     * @return the combV200
     */
    public List<SelectItem> getCombV200() {
        ComboboxUtil combo = new ComboboxUtil();
        combV200 = combo.getListComBV200DV(n750, a000, 0);
        return combV200;
    }

    /**
     * @param combV200 the combV200 to set
     */
    public void setCombV200(List<SelectItem> combV200) {
        this.combV200 = combV200;
    }

    /**
     * @return the V200
     */
    public int getV200() {
        return v200;
    }

    /**
     * @param V200 the V200 to set
     */
    public void setV200(int V200) {
        this.v200 = V200;
    }

    /**
     * @return the combk100
     */
    public List<SelectItem> getCombk100() {
        ComboboxUtil combo = new ComboboxUtil();
        combk100 = combo.getListCombK100DV(n750, a000, v200);
        return combk100;
    }

    /**
     * @param combk100 the combk100 to set
     */
    public void setCombk100(List<SelectItem> combk100) {
        this.combk100 = combk100;
    }

    /**
     * @return the pk100
     */
    public int getPk100() {
        return pk100;
    }

    /**
     * @param pk100 the pk100 to set
     */
    public void setPk100(int pk100) {
        this.pk100 = pk100;
    }

    /**
     * @return the comb4N750
     */
    public List<SelectItem> getComb4N750() {
        ComboboxUtil combo = new ComboboxUtil();
        comb4N750 = combo.getlistCombN750DV();
        return comb4N750;
    }

    /**
     * @param comb4N750 the comb4N750 to set
     */
    public void setComb4N750(List<SelectItem> comb4N750) {
        this.comb4N750 = comb4N750;
    }

    /**
     * @return the comb4A000
     */
    public List<SelectItem> getComb4A000() {
//        ComboboxUtil combo = new ComboboxUtil();
//        if (fn750 == 0) {
//            comb4A000 = new ArrayList<SelectItem>();
//            comb4A000.add(0,new SelectItem("0", getResourceString("select_city")));
//        } else {
//            System.out.println("getListCombA000DV : "+fn750);
//            comb4A000 = combo.getListCombA000DV(fn750);
//        }
//        return comb4A000;
        Object objn750 = SessionProvider.getSessionMapValue("fn750");
        if (objn750 != null) {
            try {
                fn750 = Integer.parseInt(objn750.toString());
            } catch (Exception e) {
                System.out.println("D:-- Error from convert fn750: " + e.getMessage());
                fn750 = 0;
            }
        } else {
            fn750 = 0;
        }

        ComboboxUtil combo = new ComboboxUtil();
        if (fn750 == 0) {
            comb4A000 = new ArrayList<SelectItem>();
            comb4A000.add(0, new SelectItem("0", getResourceString("select_city")));
        } else {
            System.out.println("getListCombA000DV : " + fn750);
            comb4A000 = combo.getListCombA000DV(fn750);
        }
        return comb4A000;
    }

    /**
     * @param comb4A000 the comb4A000 to set
     */
    public void setComb4A000(List<SelectItem> comb4A000) {
        this.comb4A000 = comb4A000;
    }

    /**
     * @return the comb4V200
     */
    public List<SelectItem> getComb4V200() {
//        ComboboxUtil combo = new ComboboxUtil();
//        if (fa000 == 0) {
//            comb4V200 = new ArrayList<SelectItem>();
//            comb4V200.add(0, new SelectItem("0", getResourceString("select_ldv")));
//        } else {
//        System.out.println("combo.getListComBV200DV : " + fn750 + " , " + fa000 + " , " + 0);
//        comb4V200 = combo.getListComBV200DV(fn750, fa000, 0);
//        }
//        return comb4V200;


        Object objn750 = SessionProvider.getSessionMapValue("fn750");
        Object obja000 = SessionProvider.getSessionMapValue("fa000");

        if (objn750 != null) {
            try {
                fn750 = Integer.parseInt(objn750.toString());
            } catch (Exception e) {
                System.out.println("D:-- Error from convert n750: " + e.getMessage());
                fn750 = 0;
            }
        } else {
            fn750 = 0;
        }

        if (obja000 != null) {
            try {
                fa000 = Integer.parseInt(obja000.toString());
            } catch (Exception e) {
                System.out.println("D:-- Error from convert n750: " + e.getMessage());
                fa000 = 0;
            }
        } else {
            fa000 = 0;
        }

        ComboboxUtil combo = new ComboboxUtil();
        if (fa000 == 0) {
            comb4V200 = new ArrayList<SelectItem>();
            comb4V200.add(0, new SelectItem("0", getResourceString("select_ldv")));
        } else {
            System.out.println("combo.getListComBV200DV : " + fn750 + " , " + fa000 + " , " + 0);
            comb4V200 = combo.getListComBV200DV(fn750, fa000, 0);
        }
        return comb4V200;
    }

    /**
     * @param comb4V200 the comb4V200 to set
     */
    public void setComb4V200(List<SelectItem> comb4V200) {

        this.comb4V200 = comb4V200;
    }

    /**
     * @return the comb4k100
     */
    public List<SelectItem> getComb4k100() {
//        ComboboxUtil combo = new ComboboxUtil();
//        if (fa000 == 0 && fv200 == 0) {
//            comb4k100 = new ArrayList<SelectItem>();
//            comb4k100.add(0, new SelectItem("0", getResourceString("select_ncc")));
//        } else if (fa000 != 0) {
//            comb4k100 = combo.getListCombK100DV(fn750, fa000, 0);
//
//        } else {
//        comb4k100 = combo.getListCombK100DV(fn750, fa000, fv200);
//        }
//
//        return comb4k100;

        Object objn750 = SessionProvider.getSessionMapValue("fn750");
        Object obja000 = SessionProvider.getSessionMapValue("fa000");
        Object objfv200 = SessionProvider.getSessionMapValue("fv200");

        if (objn750 != null) {
            try {
                fn750 = Integer.parseInt(objn750.toString());
            } catch (Exception e) {
                System.out.println("D:-- Error from convert fn750: " + e.getMessage());
                fn750 = 0;
            }
        } else {
            fn750 = 0;
        }

        if (obja000 != null) {
            try {
                fa000 = Integer.parseInt(obja000.toString());
            } catch (Exception e) {
                System.out.println("D:-- Error from convert fa000: " + e.getMessage());
                fa000 = 0;
            }
        } else {
            fa000 = 0;
        }

        if (objfv200 != null) {
            try {
                fv200 = Integer.parseInt(objfv200.toString());
            } catch (Exception e) {
                System.out.println("D:-- Error from convert objfv200: " + e.getMessage());
                fv200 = 0;
            }
        } else {
            fv200 = 0;
        }


        ComboboxUtil combo = new ComboboxUtil();
        if (fa000 == 0 && fv200 == 0) {
            comb4k100 = new ArrayList<SelectItem>();
            comb4k100.add(0, new SelectItem("0", getResourceString("select_ncc")));
        } else if (fa000 != 0) {
            comb4k100 = combo.getListCombK100DV(fn750, fa000, 0);
            comb4k100.remove(0);

        } else {
            comb4k100 = combo.getListCombK100DV(fn750, fa000, fv200);
            comb4k100.remove(0);
        }
        System.out.println("getListCombK100DV: " + " ,  " + fn750 + " ,  " + fa000 + " ,  " + fv200);

        return comb4k100;
    }

    /**
     * @param comb4k100 the comb4k100 to set
     */
    public void setComb4k100(List<SelectItem> comb4k100) {
        this.comb4k100 = comb4k100;
    }

    /**
     * @return the vv228
     */
    public String getVv228() {
        return vv228;
    }

    /**
     * @param vv228 the vv228 to set
     */
    public void setVv228(String vv228) {
        this.vv228 = vv228;
    }

    /**
     * @return the pagecurent
     */
    public String getPagecurent() {
        return pagecurent;
    }

    /**
     * @param pagecurent the pagecurent to set
     */
    public void setPagecurent(String pagecurent) {
        this.pagecurent = pagecurent;
    }

    /**
     * @return the vd221st
     */
    public String getVd221st() {
        return vd221st;
    }

    /**
     * @param vd221st the vd221st to set
     */
    public void setVd221st(String vd221st) {
        this.vd221st = vd221st;
    }

    /**
     * @return the vd222st
     */
    public String getVd222st() {
        return vd222st;
    }

    /**
     * @param vd222st the vd222st to set
     */
    public void setVd222st(String vd222st) {
        this.vd222st = vd222st;
    }

    /**
     * @return the vv227
     */
    public String getVv227() {
        return vv227;
    }

    /**
     * @param vv227 the vv227 to set
     */
    public void setVv227(String vv227) {
        this.vv227 = vv227;
    }

    /**
     * @return the Offset
     */
    public int getOffset() {
        return Offset;
    }

    /**
     * @param Offset the Offset to set
     */
    public void setOffset(int Offset) {
        this.Offset = Offset;
    }

    /**
     * @return the Limit
     */
    public int getLimit() {
        return Limit;
    }

    /**
     * @param Limit the Limit to set
     */
    public void setLimit(int Limit) {
        this.Limit = Limit;
    }

    // property for paging
    /**
     * @return the current
     */
    public int getCurrent() {
        if (current > totalpage) {
            current = totalpage;
        } else if (current < 1) {
            current = 1;
        }
        return current;
    }

    /**
     * @param current the current to set
     */
    public void setCurrent(int current) {

        start = (current - 1) * getNumrow();
        end = current * numrow;
        this.current = current;
    }

    /**
     * @return the numrow
     */
    public int getNumrow() {
        if (numrow == 0) {
            numrow = 30;
        }
        return numrow;
    }

    /**
     * @param numrow the numrow to set
     */
    public void setNumrow(int numrow) {
        this.numrow = numrow;
    }

    /**
     * @return the start
     */
    public int getStart() {
        if (start == 0) {
            start = 1;
        }
        return start;
    }

    /**
     * @param start the start to set
     */
    public void setStart(int start) {
        this.start = start;
    }

    /**
     * @return the end
     */
    public int getEnd() {
        if (end == 0) {
            end = 20;
        }
        return end;
    }

    /**
     * @param end the end to set
     */
    public void setEnd(int end) {
        this.end = end;
    }

    /**
     * @return the totalrow
     */
    public int getTotalrow() {
        return totalrow;
    }

    /**
     * @param totalrow the totalrow to set
     */
    public void setTotalrow(int totalrow) {
//        if (totalrow == 0) {
//            totalrow = 100;
//        }
        totalpage = totalrow / numrow;

        if (totalrow % numrow > 0) {
            totalpage = totalpage + 1;
        }


        if (getTotalpage() <= 10) {
            setStartpage(1);
            setEndpage(getTotalpage());

        } else {
            setStartpage(current - 5);
            setEndpage(current + 5);


        }
        this.totalrow = totalrow;
    }

    /**
     * @return the startpage
     */
    public int getStartpage() {
        if (startpage < 1) {
            startpage = 1;
        }
        return startpage;
    }

    /**
     * @param startpage the startpage to set
     */
    public void setStartpage(int startpage) {
        this.startpage = startpage;
    }

    /**
     * @return the endpage
     */
    public int getEndpage() {
        if (endpage > totalpage) {
            endpage = totalpage;
        }
        return endpage;
    }

    /**
     * @param endpage the endpage to set
     */
    public void setEndpage(int endpage) {

        this.endpage = endpage;
    }

    /**
     * @return the totalpage
     */
    public int getTotalpage() {
//        if (totalpage == 0) {
//            totalpage = 10;
//        }
        return totalpage;
    }

    /**
     * @param totalpage the totalpage to set
     */
    public void setTotalpage(int totalpage) {
        this.totalpage = totalpage;
    }

    /**
     * @return the pagename
     */
    public String getPagename() {
        return pagename;
    }

    /**
     * @param pagename the pagename to set
     */
    public void setPagename(String pagename) {
        this.pagename = pagename;
    }

    /**
     * @return the totalcurent
     */
    public int getTotalcurent() {
        return totalcurent;
    }

    /**
     * @param totalcurent the totalcurent to set
     */
    public void setTotalcurent(int totalcurent) {
        this.totalcurent = totalcurent;
    }
}
